// wglinstance.cpp
//

#include "config.h"
#include "wgl/wglinstance.hpp"

using namespace wgl;



Instance *Instance::current_instance{nullptr};



// Instance::Instance
//
Instance::Instance ()
{
  SDL_Init(SDL_INIT_VIDEO);
  if (SDL_GL_LoadLibrary(nullptr) != 0)
    WGL_FATAL("could not load GL library: %s", SDL_GetError());

  if (!current_instance)
    current_instance = this;
}



// Instance::~Instance
//
Instance::~Instance ()
{
  SDL_GL_UnloadLibrary();
  SDL_Quit();
}



// Instance::get_current_instance
//
Instance *Instance::get_current_instance ()
{
  return current_instance;
}



// Instance::enable_application_layers
//
void Instance::enable_application_layers ( const std::vector<std::string> &layers )
{
  enabled_application_layers.insert(enabled_application_layers.end(),
                                    layers.begin(),
                                    layers.end());
}



// Instance::get_enabled_application_layers
//
const std::vector<std::string> &Instance::get_enabled_application_layers ()
{
  return enabled_application_layers;
}
